home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / mg2a_src.zip / SYS / AMIGA / TTYICON.C < prev    next >
C/C++ Source or Header  |  1988-08-23  |  3KB  |  120 lines

  1. /*
  2.  * Name:    MG 2a
  3.  *        Iconify the MG window using Leo Schwab's iconify() routine.
  4.  * Last Edit:    07-Jan-88    mic@emx.utexas.edu
  5.  * Created:    04-Jan-88    mic@emx.utexas.edu
  6.  */
  7.  
  8. #ifdef    DO_ICONIFY
  9.  
  10. #include <exec/types.h>
  11. #include <exec/memory.h>
  12. #include <intuition/intuition.h>
  13. #include "iconify.h"
  14. #undef    TRUE
  15. #undef    FALSE
  16. #include "def.h"
  17.  
  18. /*
  19.  * Simple Mg 2a icon image.  We need a more imaginative one.
  20.  */
  21.  
  22. UWORD mg2a[160] = {
  23. /* Bit Plane #0 */
  24.  
  25.    0x0000,0x0000,0x0000,0x0000,
  26.    0x3fff,0xffff,0xffff,0xf000,
  27.    0x3fff,0xffff,0xffff,0xf000,
  28.    0x3c00,0x0000,0x0000,0xf000,
  29.    0x3cc1,0x8f80,0x0000,0xf000,
  30.    0x3ce3,0x9ce0,0x0000,0xf000,
  31.    0x3cf7,0xb800,0x0000,0xf000,
  32.    0x3cff,0xb9e0,0x0000,0xf000,
  33.    0x3cfb,0xb8e0,0x0000,0xf000,
  34.    0x3ce3,0x9ce3,0xf000,0xf000,
  35.    0x3ce3,0x8fe7,0x3800,0xf000,
  36.    0x3c00,0x0000,0x39f8,0xf000,
  37.    0x3c00,0x0000,0xf01c,0xf000,
  38.    0x3c00,0x0003,0x80fc,0xf000,
  39.    0x3c00,0x0007,0x3b1c,0xf000,
  40.    0x3c00,0x0007,0xf9ee,0xf000,
  41.    0x3c00,0x0000,0x0000,0xf000,
  42.    0x3fff,0xffff,0xffff,0xf000,
  43.    0x3fff,0xffff,0xffff,0xf000,
  44.    0x0000,0x0000,0x0000,0x0000,
  45.  
  46. /* Bit Plane #1 */
  47.  
  48.    0xffff,0xffff,0xffff,0xfc00,
  49.    0xffff,0xffff,0xffff,0xfc00,
  50.    0xf000,0x0000,0x0000,0x3c00,
  51.    0xf000,0x0000,0x0000,0x3c00,
  52.    0xf040,0x8000,0x0000,0x3c00,
  53.    0xf020,0x8420,0x0000,0x3c00,
  54.    0xf010,0x8800,0x0000,0x3c00,
  55.    0xf000,0x8820,0x0000,0x3c00,
  56.    0xf020,0x8820,0x0000,0x3c00,
  57.    0xf020,0x8420,0x1000,0x3c00,
  58.    0xf020,0x8021,0x0800,0x3c00,
  59.    0xf000,0x0000,0x0808,0x3c00,
  60.    0xf000,0x0000,0x1004,0x3c00,
  61.    0xf000,0x0000,0x8004,0x3c00,
  62.    0xf000,0x0001,0x0804,0x3c00,
  63.    0xf000,0x0000,0x0802,0x3c00,
  64.    0xf000,0x0000,0x0000,0x3c00,
  65.    0xf000,0x0000,0x0000,0x3c00,
  66.    0xffff,0xffff,0xffff,0xfc00,
  67.    0xffff,0xffff,0xffff,0xfc00
  68. };
  69.  
  70. static struct Image iconimg = {        /*  Icon Image  */
  71.      0, 0,
  72.     54, 20, 2,
  73.     NULL,    /* filled in later */
  74.     0x3, 0,
  75.     NULL
  76. };
  77.  
  78. /*
  79.  * Iconify MG's window using tthide(), iconify(), and ttshow().
  80.  */
  81.  
  82. int tticon(f, n)
  83. {
  84.     static UWORD    iconX = 0, iconY = 0;
  85.     UWORD        *chipbitmap;
  86.     struct Image    *chipimg;
  87.     extern short    toggling;
  88.     extern APTR    AllocMem();
  89.  
  90.     /* copy the bitmap into chip memory */
  91.     if (NULL == (chipbitmap = (UWORD * )
  92.         AllocMem((ULONG) sizeof(mg2a), MEMF_CHIP | MEMF_PUBLIC))) {
  93.         ewprintf("Can't allocate image bitmap");
  94.         return FALSE;
  95.     }
  96.     bcopy((char *)mg2a, (char *)chipbitmap, (int) sizeof(mg2a));
  97.  
  98.     /* copy the image structure too */
  99.     if (NULL == (chipimg = (struct Image *)
  100.         AllocMem((ULONG) sizeof(iconimg), MEMF_CHIP | MEMF_PUBLIC))) {
  101.         FreeMem(chipbitmap, (ULONG) sizeof(iconimg));
  102.         ewprintf("Can't allocate image structure");
  103.         return FALSE;
  104.     }
  105.     bcopy((char *)&iconimg, (char *)chipimg, (int) sizeof(iconimg));
  106.     chipimg->ImageData = chipbitmap;
  107.  
  108.     /* hide the window, display the icon, then redisplay the window */
  109.     tthide(FALSE);    /* not resizing */
  110.  
  111.     iconify(&iconX, &iconY, chipimg->Width, chipimg->Height, NULL,
  112.         (APTR) chipimg, (int) ICON_IMAGE); /* iconify    */
  113.     FreeMem(chipimg, (ULONG) sizeof(iconimg));
  114.     FreeMem(chipbitmap, (ULONG) sizeof(mg2a));
  115.  
  116.     ttshow(FALSE);    /* no resize */
  117.     return TRUE;
  118. }
  119. #endif DO_ICONIFY
  120.